package com.xixiake.utils;

import android.content.Context;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.xixiake.application.BaseApplication;

/**
 * 设备信息获取类
 * Created by c-wanghengli on 2017/4/16.
 */
public class DeviceUtil {

    private static String deviceId = "";

    /**
     * 获取手机IMEI
     * @return
     */
    public static String getIMEI(){
        if(deviceId != null && deviceId.length() > 0){
            return deviceId;
        }
        Context context = BaseApplication.getContext();
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
        deviceId = telephonyManager.getDeviceId();
        if(TextUtils.isEmpty(deviceId) || "000000000000000".equals(deviceId)){
            deviceId = "0";
        }
        return deviceId;
    }
}
